package com.example.safeassistan.home.adapter;

import android.widget.ImageView;
import androidx.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.safeassistan.R;
import com.example.safeassistan.risk.model.WarningListModel;
import java.util.List;

public class WarnningListAdapter extends BaseQuickAdapter <WarningListModel.ResultDTO.RecordsDTO,BaseViewHolder>{
    public WarnningListAdapter(@Nullable List data) {
        super(R.layout.item_warnning_list, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, WarningListModel.ResultDTO.RecordsDTO item) {
        ImageView ivRiskLevel=helper.getView(R.id.ivRiskLevel);

        helper.setText(R.id.tvTime,item.getCreateTime());
        helper.setText(R.id.tvRiskPointTitle,item.getRiskName());
        helper.setText(R.id.tvOwnDepart,"所属单位："+item.getDepartName());

        switch (item.getRiskLevel()){
            case 1:
                //重大
                ivRiskLevel.setImageResource(R.mipmap.icon_shan_red_circle);
                break;
            case 2:
                //较大
                ivRiskLevel.setImageResource(R.mipmap.icon_shan_orange_circle);
                break;
            case 3:
                //一般
                ivRiskLevel.setImageResource(R.mipmap.icon_shan_yellow_circle);
                break;
            case 4:
                //重大
                ivRiskLevel.setImageResource(R.mipmap.icon_shan_blue_circle);
                break;
        }

        switch (item.getReason()){
            case "1":
                helper.setText(R.id.tvReason,"任务逾期");
                helper.setText(R.id.tvContent,"任务["+item.getTaskName()+
                        "]-部门["+item.getDepartName()+"]-岗位["+item.getName()+"]任务检查逾期");

                break;
            case "2":
                helper.setText(R.id.tvReason,"隐患");
                helper.setText(R.id.tvContent,"隐患：\"有隐患\"正在整改中");
                break;
        }
    }
}
